package com.shop.controller;

import com.mybatisflex.core.paginate.Page;
import com.shop.entity.ShopOrderRefund;
import com.shop.service.ShopOrderRefundService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;

/**
 * 售后单记录表 控制层。
 *
 * @author 彭新才 
 * @since 2024-10-14
 */
@RestController
@Tag(name = "售后单记录表接口")
@RequestMapping("/shopOrderRefund")
public class ShopOrderRefundController {

    @Autowired
    private ShopOrderRefundService shopOrderRefundService;

    /**
     * 添加售后单记录表。
     *
     * @param shopOrderRefund 售后单记录表
     * @return {@code true} 添加成功，{@code false} 添加失败
     */
    @PostMapping("save")
    @Operation(summary = "保存售后单记录表")
    public boolean save(@RequestBody @Parameter(description = "售后单记录表") ShopOrderRefund shopOrderRefund) {
        return shopOrderRefundService.save(shopOrderRefund);
    }

    /**
     * 根据主键删除售后单记录表。
     *
     * @param id 主键
     * @return {@code true} 删除成功，{@code false} 删除失败
     */
    @DeleteMapping("remove/{id}")
    @Operation(summary = "根据主键删除售后单记录表")
    public boolean remove(@PathVariable @Parameter(description = "售后单记录表主键") Serializable id) {
        return shopOrderRefundService.removeById(id);
    }

    /**
     * 根据主键更新售后单记录表。
     *
     * @param shopOrderRefund 售后单记录表
     * @return {@code true} 更新成功，{@code false} 更新失败
     */
    @PutMapping("update")
    @Operation(summary = "根据主键更新售后单记录表")
    public boolean update(@RequestBody @Parameter(description = "售后单记录表主键") ShopOrderRefund shopOrderRefund) {
        return shopOrderRefundService.updateById(shopOrderRefund);
    }

    /**
     * 查询所有售后单记录表。
     *
     * @return 所有数据
     */
    @GetMapping("list")
    @Operation(summary = "查询所有售后单记录表")
    public List<ShopOrderRefund> list() {
        return shopOrderRefundService.list();
    }

    /**
     * 根据售后单记录表主键获取详细信息。
     *
     * @param id 售后单记录表主键
     * @return 售后单记录表详情
     */
    @GetMapping("getInfo/{id}")
    @Operation(summary = "根据主键获取售后单记录表")
    public ShopOrderRefund getInfo(@PathVariable Serializable id) {
        return shopOrderRefundService.getById(id);
    }

    /**
     * 分页查询售后单记录表。
     *
     * @param page 分页对象
     * @return 分页对象
     */
    @GetMapping("page")
    @Operation(summary = "分页查询售后单记录表")
    public Page<ShopOrderRefund> page(@Parameter(description = "分页信息") Page<ShopOrderRefund> page) {
        return shopOrderRefundService.page(page);
    }

}
